package com.axxc.jpa.pattendegign.commons;

import com.axxc.jpa.pattendegign.adapter.AClassAdaapter;
import com.axxc.jpa.pattendegign.adapter.AInterfaceAdapter;
import com.axxc.jpa.pattendegign.adapter.AObjectAdapter;
import com.axxc.jpa.pattendegign.adapter.Ps2;
import com.axxc.jpa.pattendegign.adapter.Ps2ObjectAdapter;
import com.axxc.jpa.pattendegign.adapter.Usb;
import com.axxc.jpa.pattendegign.adapter.UsbClassAdapter;
import com.axxc.jpa.pattendegign.adapter.Usber;

/**
 * @ClassName TestAdapterPatten
 * @Description //TODO 测试三种适配器模式
 * @author xxc
 * @data 2018年9月4日下午10:36:48
 * @see {@link http://gitee.com/biuabiu/ }
 */
public class TestAdapterPatten {

	public static void main(String[] args) {
		testClassAdapter();
		testObjectAdapter();
		testInterfaceAdapter();
	}

	/**
	 * 接口适配器模式
	 */
	private static void testInterfaceAdapter() {

		new AInterfaceAdapter().a();
		new AClassAdaapter().classAdapter(new UsbClassAdapter());// 另类装饰者模式
		new AObjectAdapter().objectAdapter(new Ps2ObjectAdapter<Usb>(new Usber())).isPs2();// 另类装饰者模式
	}

	/**
	 * 类适配模式
	 */
	public static void testClassAdapter() {
		Usb usbClassAdapter = new UsbClassAdapter();
		usbClassAdapter.isUsb();
	}

	/**
	 * 对象适配器模式
	 */
	public static void testObjectAdapter() {
		Ps2 ps2 = new Ps2ObjectAdapter<>(new Usber());
		ps2.isPs2();
	}
}
